<?php
/**
 * User: Netman
 * Date: 14-3-27
 * Time: 下午9:53
 */

class Stourweb_Controller extends Class_Controller {

    /*
     * before
     */
    public function before()
    {
        parent::before();
    }
    /*
 * 显示模板
 * @param string $tpl,模板名
 * */
    public function display($tpl,$replace= array())
    {


        $file = $GLOBALS['cfg_templet'].$tpl;

        if(!file_exists(APPPATH.'/views/'.$GLOBALS['cfg_templet'].'/'.$tpl.'.php'))
        {
            $file = 'default/'.$tpl;
        }

        $view = Stourweb_View::factory($file);

        foreach($this->_data as $key=>$value)
        {
            $view->set($key,$value);
        }
        $body = $view->render();
        if($replace)
        {
            foreach($replace as $k => $v)
            {
                $body = str_replace($k,$v,$body);
            }
        }
        $this->response->body($body);


    }
}

